/*
 * File Name : node.cpp
 * Auther : dream.liuguobiao
 * Create Date : 2010-5-6
 * Last Edit : 2010-5-6
 */

#include "node.h"
#include <string>
#include <stack>

#include <iostream>

node::node()
:name("unnamed"),path(""),brother(NULL),father(NULL),mod(0644),userID(0),groupID(0)
{


}

std::string *node::get_name(){
  return &name;
}

std::string *node::get_path(){
  std::stack<node*> nodes;
  node *tmp_node = this;
  path = "";
  do{
    nodes.push(tmp_node);
    tmp_node = tmp_node->get_father();
  }while( NULL != tmp_node);
    nodes.pop();
    if( 0 == nodes.size() )
      path += "/";
  while( 0  < nodes.size() ){
    tmp_node = nodes.top();
    path += "/";
    path += *(tmp_node->get_name() );
    nodes.pop();
  }
  return &path;
}

bool node::set_name( std::string *new_name ){
this->name = *new_name;
return true;
}

node *node::get_brother(){
return brother;
}

bool node::set_brother( node *new_brother ){
  brother = new_brother;
  return true;
}

node *node::get_father(){
return father;
}
bool node::set_father( node *new_father ){
  father = new_father;
  return true;

}

int node::get_mod(){
return this->mod;
}

bool node::set_mod( int new_mod ){
mod = new_mod;
return true;
}

